import numpy as np

max_ = np.array([0.000001000000000000,0.000001000000000000,0.000001000000000000,134.050376700000,133.951015900000,134.044191000000,534.401791400000,510.667450200000,523.831242000000,943.259772200000,925.503159100000,933.329625600000,134.049698300000,134.019683000000,134.044808800000,521.220695900000,541.763350100000,532.032705800000,899.990461700000,939.374705700000,963.782414500000,238.454116300000,170.336863600000,238.414440800000,492.915243900000,355.842707500000,491.898713200000,598.256805700000,471.341348800000,589.611193800000,662.316033300000,414.408692100000,670.761001600000,593.498872100000,374.001271800000,552.863080400000,761.219754100000,608.869855800000,716.824695200000,858.855435300000,847.488364000000,863.720364500000,542.954895600000,371.062785400000,544.668207200000,752.676812200000,619.850004100000,708.803843000000,902.883643400000,865.832207900000,888.924088700000])
min_ = np.array([0,0,0,-134.050452600000,-134.020437200000,-134.045563200000,-531.301939100000,-448.218303400000,-535.422758100000,-932.144590100000,-690.706581100000,-902.307289300000,-134.049623100000,-133.950277800000,-134.043436400000,-533.117986300000,-449.152447700000,-558.943546200000,-899.034650500000,-883.144888900000,-893.892840900000,-238.450265000000,-238.464574200000,-238.399005300000,-491.876099700000,-493.723777100000,-491.844230200000,-597.086566900000,-606.626505100000,-597.794661700000,-664.418335400000,-708.785559300000,-668.809297300000,-598.081346000000,-527.884101300000,-557.186766400000,-777.388279600000,-763.312146700000,-735.998380300000,-835.833828100000,-1009.35724400000,-944.278308000000,-542.582083700000,-551.333647700000,-531.033749200000,-750.074941100000,-766.795028800000,-719.105211000000,-888.761865200000,-1015.27991100000,-954.931541800000])

max_16 = np.array([0.0001,0.0001,0.0001,134.0503767,133.9510159,134.044191,534.4017914,510.6674502,523.831242,943.2597722,925.5031591,933.3296256,134.0496983,134.019683,134.0448088,521.2206959,541.7633501,532.0327058,899.9904617,939.3747057,963.7824145,238.4541163,170.3368636,238.4144408,492.9152439,355.8427075,491.8987132,662.3160333,414.4086921,670.7610016,593.4988721,374.0012718,552.8630804,761.2197541,608.8698558,716.8246952,858.8554353,847.488364,863.7203645,542.9548956,371.0627854,544.6682072,752.6768122,619.8500041,708.803843,902.8836434,865.8322079,888.9240887])
min_16 = np.array([0,0,0,-134.0504526,-134.0204372,-134.0455632,-531.3019391,-448.2183034,-535.4227581,-932.1445901,-690.7065811,-902.3072893,-134.0496231,-133.9502778,-134.0434364,-533.1179863,-449.1524477,-558.9435462,-899.0346505,-883.1448889,-893.8928409,-238.450265,-238.4645742,-238.3990053,-491.8760997,-493.7237771,-491.8442302,-664.4183354,-708.7855593,-668.8092973,-598.081346,-527.8841013,-557.1867664,-777.3882796,-763.3121467,-735.9983803,-835.8338281,-1009.357244,-944.278308,-542.5820837,-551.3336477,-531.0337492,-750.0749411,-766.7950288,-719.105211,-888.7618652,-1015.279911,-954.9315418])

def read_3dpredict(annos_path, label_len,is_gt):
    records = []
    with open(annos_path, 'rb') as fr:
        for line in fr:
            tmp = line.split(',')
            if is_gt:
                coords = [float(x) for x in tmp[0 : label_len]]
            else:
                coords = [float(x) for x in tmp[1 : label_len + 1]]
            records.append(np.array(coords))
            
        size = len(records)
        print "reading {0} images ...".format(size)
        if size < 1:
            print "Read txt file failure ..."
        
    return records

def read_2dpredict(annos_path):
    records = []
    with open(annos_path, 'rb') as fr:
        for line in fr:
            tmp = line.split(',')
            coords = [float(x) for x in tmp[1 : ]]
            records.append(np.array(coords))
        size = len(records)
        print "reading {0} images ...".format(size)
        if size < 1:
            print "Read txt file failure ..."
        
    return records

def readlfile(annos_path, label_len):
    records = []
    filename = []
    with open(annos_path, 'rb') as fr:
        for line in fr:
            # print( line.split(" "))
            filepath, label = line.strip().split(" ")
            tmp = label.split(',')
            coords = [float(x) for x in tmp[0 : label_len]]
            records.append(np.array(coords))
            filename.append('/home/jiangchenhan/data/human3.6m/'+filepath)
            
    size = len(records)
    print "reading {0} images ...".format(size)
    if size < 1:
        print "Read txt file failure ..."
        
    return records,filename
